Letter Combinations of a Phone Number
Question
You are given a string of digits from 2-9 (inclusive), where each digit is mapped to letters based on this phone keypad layout:
Generate all unique combinations of letters that can be formed by pressing these digits on the keypad.
Input: digits = "65"
Output: ["mj", "mk", "ml", "nj", "nk", "nl", "oj", "ok", "ol"]
4 can represent "m", "n", or "o" while 5 can represent "j", "k", or "l".
Input: digits = "9"
Output: ["w", "x", "y", "z"]
4 can represent "w", "x", "y", "z".
Clarify the problem
What are some questions you'd ask an interviewer?
Understand the problem
How many unique combinations are there when digits = "59"?
5
7
9
12
All test cases pass! 🎉
Time limit exceeded
InputExpected OutputActual Output
Standard OutputScroll down...
Login or signup to save your code.
Uh oh... looks like you don't yet have access.
Not sure what this unlocks? Check out a free pattern section.